<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'AddExp.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="https://cdn.staticfile.org/foundation/5.5.3/css/foundation.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/foundation/5.5.3/js/foundation.min.js"></script>
    <script src="https://cdn.staticfile.org/foundation/5.5.3/js/vendor/modernizr.js"></script>

  </head>
  <script type="text/javascript">
  	function validateForm() {
    var x = document.forms["myForm"]["beg"].value;
    var y = document.forms["myForm"]["end"].value;
    var name = document.forms["myForm"]["ename"].value;
    var retNum = /^\d*$/;
    if(parseInt(x)>parseInt(y)){
    	alert("选择不合法，开始周次应小于结束周次!");
    	return false;
    }else if(name==null || name==""){
    	alert("输入不能为空!");
    	return false;
    }
   // else if(name!=/^[\u0391-\uFFE5A-Za-z]+$/||(!retNum.test(name))){
   // 	alert("实验名只能输入中文、英文和数字");
   // 	return false;
    //}
    return true;
}
  </script>
  <%
  String tid=(String)request.getAttribute("tid");
  String tname=(String)request.getAttribute("tname");
  int beg=1;
  int end=22;
   %>
   
  <body style="background:url(images/back6.jpg);background-size:100% 100% ; background-attachment: fixed"
  style="padding:20px;">
  <table align="center">
  	<form  name="myForm" action="servlet/MyExpServlet" onsubmit="return validateForm()" method="get">
  	<input type="hidden" name="op" value="add2">
  	<input type="hidden" name="tid" value=<%=tid %>>
  	<input type="hidden" name="tname" value=<%=tname %>>
  	<tr>
   		<td>实验名</td><td><input type="text" name="ename"  maxlength="6"></td>
 	</tr>
 	<tr>
   		<td>实验开始周次</td>
   		<td>
   			<select name="beg">
   					<% for(int i=beg;i<=end;i++){ %>
   						<option value=<%=i %>><%="第"+i+"周" %></option>
   					<% } %>
   			</select>
   		</td>
   </tr>
   <tr>
	   <td>实验结束周次</td>
	   <td>
		   <select name="end">
			   				<% for(int i=beg;i<=end;i++){ %>
		   						<option value=<%=i %>><%="第"+i+"周" %></option>
		   					<% } %>
		   </select>
	   </td>
   </tr>
   <tr>
	   <td>类型</td>
	   <td>
		   <select name="type">
		   		<option value="1">硬件</option>
		   		<option value="2">软件</option>
		   </select>
	   </td>
   </tr>
   <tr>
	   <td></td>
	   <td>
		   <input type="submit" value="添加">
		   <a href="servlet/MyExpServlet?tid=<%=tid%>&tname=<%=tname%>">返回</a>
	   </td>
   </tr>
   </form>
 </table>
   
  </body>
</html>
